﻿using System.Security.Cryptography;
using CoHubServerCore.Configurator;
using CoHubServerCore.Protocol;
using CoHubServerCore.Security;
using CoHubServerCore.Tcp;
using Aes = CoHubServerCore.Security.Aes;
using Path = CoHubServerCore.Configurator.Path;

Config config = Config.Load();
Console.WriteLine(config.Network.DomainName);
Path path = new(config);
config.Save();
return;

Aes aes = new Aes(5);
Console.WriteLine(aes.Decrypt(aes.Encrypt("Hello")));

return;

void Reply(TcpClient client, string message)
{
    Console.WriteLine($"Recv from {client.Guid}: {message}");
    client.Send($"Send: Hello. {client.RemoteEndPoint} I hear {message} from you.");
}

TcpServer server = new(2333);
server.ClientCycleEvent += Reply;

server.Start();

Console.Read();

return;
#if false
Packet packet =
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        new Packet(Guid.NewGuid(), Guid.NewGuid(), Guid.NewGuid(), DateTime.Now, 0,0,0, new CoHubServerCore.Service.FreshClient.Request());
Console.WriteLine(packet.ToJson());

Aes aes = new Aes();
Console.WriteLine(aes.Encrypt("12aaaaaaaaaaa34"));

return;

Rsa rsa = new Rsa();
Console.WriteLine(rsa.PublicKey);
Console.WriteLine();
Console.WriteLine(rsa.PrivateKey);
Console.WriteLine();
var secret = rsa.Encrypt("CoHubServerRsaTest");
Console.WriteLine(secret);

Console.WriteLine(rsa.Decrypt(secret));

#endif